﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;

namespace WCS.Infrastructure.EFCore;

/// <summary>
/// 订单退款记录表
/// </summary>
[Table("OrderRefundRecord")]
[Index("OrderId", Name = "OrderRefundRecord_OrderId_idx")]
[Index("OutRefundNo", Name = "OrderRefundRecord_OutRefundNo_idx", IsUnique = true)]
[Index("OutTradeNo", Name = "OrderRefundRecord_OutTradeNo_idx")]
[Index("TransactionNo", Name = "OrderRefundRecord_TransactionNo_idx")]
public partial class OrderRefundRecord
{
    /// <summary>
    /// 订单退款ID
    /// </summary>
    [Key]
    [StringLength(32)]
    public string Id { get; set; } = null!;

    /// <summary>
    /// 订单ID
    /// </summary>
    [StringLength(32)]
    public string OrderId { get; set; } = null!;

    /// <summary>
    /// 商户编号
    /// </summary>
    [StringLength(32)]
    public string CustomerCode { get; set; } = null!;

    /// <summary>
    /// 商户退款单号（退款单号，代表本次退款申请交易）
    /// </summary>
    [StringLength(64)]
    public string OutRefundNo { get; set; } = null!;

    /// <summary>
    /// 商户订单号
    /// </summary>
    [StringLength(32)]
    public string OutTradeNo { get; set; } = null!;

    /// <summary>
    /// 易票联订单号
    /// </summary>
    [StringLength(255)]
    public string? TransactionNo { get; set; }

    /// <summary>
    /// 商户分账单号（拆单分账时有效）
    /// </summary>
    [StringLength(64)]
    public string? OutSplitTradeNo { get; set; }

    /// <summary>
    /// 申请退款金额（单位分）
    /// </summary>
    public long RefundAmount { get; set; }

    /// <summary>
    /// 原订单金额（单位分）
    /// </summary>
    public long OriginalAmount { get; set; }

    /// <summary>
    /// 商品订单信息
    /// </summary>
    [Column(TypeName = "jsonb")]
    public string? OrderInfo { get; set; }

    /// <summary>
    /// 退款申请说明
    /// </summary>
    [StringLength(500)]
    public string? Remark { get; set; }

    /// <summary>
    /// 退款结果通知地址
    /// </summary>
    [StringLength(255)]
    public string? NotifyUrl { get; set; }

    /// <summary>
    /// 分账退款信息列表（JSON格式）
    /// </summary>
    [Column(TypeName = "jsonb")]
    public string? SplitInfoList { get; set; }

    /// <summary>
    /// 退款路径（JSON格式）
    /// </summary>
    [Column(TypeName = "jsonb")]
    public string? ReturnToList { get; set; }

    /// <summary>
    /// 随机字符串
    /// </summary>
    [StringLength(32)]
    public string? NonceStr { get; set; }

    /// <summary>
    /// 退款手续费（单位分）
    /// </summary>
    public long? ProcedureFee { get; set; }

    /// <summary>
    /// 退回收单手续费（单位分）
    /// </summary>
    public long? BackpayProcedurefee { get; set; }

    /// <summary>
    /// 退回分账手续费（单位分）
    /// </summary>
    public long? BackSplitProcedureFee { get; set; }

    /// <summary>
    /// 上游订单号
    /// </summary>
    [StringLength(64)]
    public string? ChannelTradeNo { get; set; }

    /// <summary>
    /// 退款执行结果
    /// </summary>
    [StringLength(10)]
    public string? RefundState { get; set; }

    /// <summary>
    /// 优惠退款详情（JSON格式）
    /// </summary>
    [Column(TypeName = "jsonb")]
    public string? RefundDetail { get; set; }

    /// <summary>
    /// 保留信息
    /// </summary>
    [StringLength(500)]
    public string? Reserved { get; set; }

    /// <summary>
    /// 退款时间
    /// </summary>
    [Column(TypeName = "timestamp(6) without time zone")]
    public DateTime? RefundTime { get; set; }

    /// <summary>
    /// 退款原因
    /// </summary>
    [StringLength(255)]
    public string? RefundReason { get; set; }

    /// <summary>
    /// 状态（0=处理中，1=成功，2=失败）
    /// </summary>
    public int Status { get; set; }

    /// <summary>
    /// 是否全额退款
    /// </summary>
    public bool IsAutoRefund { get; set; }

    /// <summary>
    /// 版本号
    /// </summary>
    [StringLength(256)]
    public string? Version { get; set; }

    /// <summary>
    /// 创建时间
    /// </summary>
    [Column(TypeName = "timestamp(6) without time zone")]
    public DateTime CreationTime { get; set; }

    /// <summary>
    /// 最后修改时间
    /// </summary>
    [Column(TypeName = "timestamp(6) without time zone")]
    public DateTime? LastModificationTime { get; set; }

    /// <summary>
    /// 请求参数JSON（记录完整的退款请求参数）
    /// </summary>
    [Column(TypeName = "jsonb")]
    public string? RequestData { get; set; }

    /// <summary>
    /// 回调参数JSON（记录退款回调数据）
    /// </summary>
    [Column(TypeName = "jsonb")]
    public string? CallbackData { get; set; }

    /// <summary>
    /// API响应JSON（记录退款接口响应数据）
    /// </summary>
    [Column(TypeName = "jsonb")]
    public string? ApiResponse { get; set; }

    /// <summary>
    /// 扩展属性
    /// </summary>
    [Column(TypeName = "jsonb")]
    public string? ExtraProperties { get; set; }
}
